<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>InfoRequest</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<div id="app">
    <button @click="addInfo">addInfo</button>
    <button @click="deleteInfo">deleteInfo</button>
    <button @click="updateInfo">updateInfo</button>
    <button @click="addTagForInfo">addTagForInfo</button>
    <button @click="getTagsByInfo">getTagsByInfo</button>
    <button @click="getInfoById">getInfoById</button>
</div>
<script>
    const send=(req)=>{
        axios({
            method:"post",
            url:"http://localhost:80/info",
            data:req
        }).then(function (resp) {
            console.log(resp.data)
        })
    }
    var vm=new Vue({
        el: '#app',
        methods: {
            addInfo(){
                let info={
                    name:"",
                    content:""
                };
                let req={
                    type:"req_addInfo",
                    value:info
                }
                send(req);
            },
            deleteInfo(){
                let req={
                    type:"req_deleteInfo",
                    value:"id"
                }
                send(req);
            },
            updateInfo(){
                /*在addInfo报文的基础上，info多了id*/
                let info={
                    id:"",
                    name:"",
                    content:""
                };
                let req={
                    type:"req_updateInfo",
                    value:info
                }
                send(req);
            },
            //为信息添加标签
            addTagForInfo(){
                let req={
                    type:"req_addTagForInfo",
                    value: {
                        tagId:"",
                        infoId:""
                    }
                }
                send(req);
            },
            //获取信息所有标签
            getTagsByInfo(){
                let req={
                    type:"req_getTagsByInfo",
                    value:"id"
                }
                send(req);
                let resp={
                    type:"resp_getTagsByInfo",
                    isSuccess:true,
                    value:[{...}]
                }
            },
            getInfoById(){
                let req={
                    type:"req_getInfoById",
                    value:["id1","id2","id3"]
                }
                send(req);
                let info={
                    id:"",
                    name:"",
                    content:""
                };
                let resp={
                    type:"resp_getInfoById",
                    isSuccess:true,
                    value:[info,info,info]
                }
            },
        }
    })
</script>
</body>
</html>